<template>
  <div>
    <el-input v-model="code" placeholder="请输入编号" :disabled='disabled' />
  </div>
</template>

<script>
import { genCode } from "@/api/system/code"
export default {
  name: "SelectBrand",
  props: {
    value: {
      required: true
    },
    type: {
      type: String,
      required: true
    },
    disabled: {
      type: Boolean,
      default: true
    }  
  },
  data() {
    return {
      code: this.value,
    }
  },
  watch: {
    value(newVal) {
      this.code = newVal;
    },
    code(newVal, oldVal){
      this.$emit("input", this.code)
    }
  },
  created() {
    this.genCodeFun();
  },
  methods: {
    /** 生成编号 */
    genCodeFun(){
      genCode(this.type).then(response => {
        this.code = response.data;
      })
    },
  }
};
</script>

